<template>
    <f7-page ptr @ptr:refresh="refresh" infinite :ptr-distance="$root.ptrDistance" :infinite-distance="50"
        :infinite-preloader="true" @infinite="infinite" class="detail">
        <f7-navbar>
          <f7-nav-left>
            <f7-link icon-material="arrow_back" force back></f7-link>
          </f7-nav-left>
          <f7-nav-title>涉及工程</f7-nav-title>
          <f7-nav-right @click.native="show = true">
                <img src="/static/img/toolbar.svg" alt="toolbar-icon" style="width: 22px;" />
            </f7-nav-right>
        </f7-navbar>
        <!-- 列表内容 -->
        <div class="content">
            <f7-list media-list>
                <f7-list-item v-for="(item, i) in query.data" :key="i">
                    <div slot="subtitle">
                        <div>
                            <div class="engineeName">{{ item.engineeName }}</div>
                            <section>
                                <span>
                                    <span class="img-icon"><img src="@/assets/img/qzjx/statistics/blackBox.svg" alt=""></span>
                                        黑匣子 <span class="blue-text">{{ item.onLineCount||0 }}</span>/{{ (item.onLineCount||0)+(item.offLineCount||0) }}
                                    </span>
                                <span>
                                    <span class="img-icon"><img src="@/assets/img/qzjx/statistics/camera.svg" alt=""></span>
                                    司机监控 <span class="blue-text">{{ item.videoOnLineCount||0 }}</span>/{{ (item.videoOnLineCount||0)+(item.videoOffLineCount||0) }}
                                </span>
                            </section>
                        </div>
                        <section @click="fnToList(item.engineeId)">
                            <span class="num">{{item.propertyTotal}}</span>
                            <span>起重设备</span>
                        </section>
                    </div>
                </f7-list-item>
            </f7-list>
            <van-empty description="暂无数据" v-if="!query.data.length" />
        </div>

        <!-- 弹出面板 -->
        <van-popup v-model="show" position="bottom" get-container="body" class="qm-popup"
            style="border-radius: 12px 12px 1px 1px;" close-icon="/static/img/icon_close.svg" :closeable="true">
            <div class="qm-popup-content">
                <!-- 标题 -->
                <div class="popup-title">筛选</div>
                <!-- 检索框 -->
                <van-search v-model="search.engineeName" placeholder="工程名" left-icon="/static/img/search.svg" />
                <!-- 按钮 -->
                <div class="btn-box">
                    <van-row gutter="12">
                        <van-col span="8">
                            <van-button round text="重置" class="reset" @click="cancel" />
                        </van-col>
                        <van-col span="16">
                            <van-button round text="确定" @click="submit" />
                        </van-col>
                    </van-row>
                </div>
            </div>
        </van-popup>
    </f7-page>
</template>

<script>
import Controller from "@/libs/framework/controller";
export default class index extends Controller {
    disableCache () {
        return true;
    }
    onBeforeInit () {
        this.urls = {
            // query: "/mobileApi/equipment/queryEngineeList"
            query: "/statistics/crane/queryPropertyInEngineeList"
        };
    }
    mixin () {
        return {
            data () {
                return {
                    // 筛选项显示
                    show: false,
                    query: {
                        data: [],
                    },

                    search: {
                        engineeName: '',
                    },
                };
            },
            created () {

            },
            methods: {
                fnToList(engineeId){
                    this.$f7router.navigate(`/business/qzjx/equipment/list?engineeId=${engineeId}&propertyStatus=5,6`)
                },
                cancel () {
                    for (let key in this.search) {
                        this.search[key] = "";
                    }
                    this.show = false;
                    this.searchQuery();
                },
                // 确定
                submit () {
                    this.show = false;
                    this.searchQuery();
                },
            },

        };
    }
}
</script>

<style scoped lang="less">
@import url('../../../../assets/css/commonPage.less');
.content {
    .media-list {
        --f7-list-media-item-padding-vertical: 15px;
        --f7-list-media-item-padding-horizontal: 15px;
        margin-top: 0!important;
        /deep/ul {
            background-color: transparent;
        }

        /deep/.item-link .item-inner {
            padding-right: 10px;
        }
    }

    // 列表项
    .media-item {
        margin-bottom: 10px;
        background: #ffffff;
        box-shadow: 0px 4px 18px 0px rgba(16, 67, 136, 0.1);
        border-radius: 8px;

        &:last-child {
            margin-bottom: 0;
        }

        // 标题
        /deep/.item-title {
            font-size: 16px;
            font-weight: 500;
            color: #333333;
            line-height: 23px;
        }

        // 副标题
        /deep/.item-subtitle {
            font-size: 12px;
            color: #61677a;
            line-height: 20px;
            white-space: normal;
            
            >div {
                display: flex;
                align-items: center;
                .engineeName{
                    color: #242424;
                    font-size: 16px;
                    font-weight: 600;
                }
                .blue-text{
                    color: #4b88ff;
                    margin-left:5px;
                }
                >div{
                    padding-right: 10px;
                    // border-right: 1px dashed #CFDAE2;
                    flex: 1;
                    section {
                        margin-top: 10px;
                        display: flex;
                        >span{
                            background: #F8FAFE;
                            padding: 5px 6px;
                            border-radius: 4px; 
                            display: flex;
                            align-items: center;
                            &:first-child{
                                margin-right: 8px;
                            }
                        }
                    }
                }
                .img-icon{
                    background: #ebeff5;
                    width: 20px;
                    height: 20px;
                    line-height: 24px;
                    text-align: center;
                    display: inline-block;
                    border-radius: 20px;
                    margin-right: 5px;
                    img{
                        width: 65%;
                        height: 65%;
                    }
                }
                >section{
                    flex-shrink: 0;
                    display: flex;
                    justify-content: center;
                    flex-direction: column;
                    align-items: center;
                    font-size: 12px;
                    color: #1990FF;
                    padding: 20px 10px;
                    background: linear-gradient(180deg, #F6FBFF 0%, #F1F9FF 100%);
                    border: 1px solid #EAF4FE;
                    border-radius: 4px;
                    .num{
                        font-size: 16px;
                        font-weight: 600;
                        margin-bottom: 5px;
                    }
                }
            }
        }

        // 标签
        .qm-tag {
            margin-right: 6px;
            display: inline-block;
            padding: 2px 6px;
            font-size: 13px;
            color: var(--color, #61677A);
            line-height: 19px;
            background-color: var(--bg-color, rgba(137, 149, 172, .1));
            border-radius: 4px;

            &:last-child {
                margin-right: 0;
            }
        }
    }
}

.qm-fix {
    display: flex;
    justify-content: center;
    align-items: center;
    position: fixed;
    right: 19px;
    bottom: 130px;
    width: 50px;
    height: 50px;
    font-size: 14px;
    color: #ffffff;
    line-height: 15px;
    background: linear-gradient(180deg, #58aefe 0%, #3d83fa 100%);
    box-shadow: 0px 6px 10px 0px rgba(5, 24, 66, 0.2);
    border-radius: 50%;
}

// 弹出层
.qm-popup {
    .qm-popup-content {
        padding: 20px 16px 0 16px;
        display: flex;
        flex-direction: column;
        height: 100%;
        overflow: hidden;
        box-sizing: border-box;

        .popup-title {
            flex: 0 0 auto;
            margin-bottom: 20px;
            font-size: 16px;
            font-weight: 500;
            color: #333333;
            line-height: 23px;
            text-align: center;
        }
    }

    // 弹出框关闭按钮
    /deep/.van-popup__close-icon {
        top: 20px;

        img {
            width: 15px;
        }
    }

    // 搜索框
    .van-search {
        flex: 0 0 auto;
        padding: 0;
        height: 36px;

        /deep/.van-search__content {
            background-color: #f5f7fa;
            border-radius: 18px;

            .van-field__left-icon {
                display: flex;
                align-items: center;
            }

            input {
                &::placeholder {
                    font-size: 14px;
                    color: #61677a;
                    line-height: 20px;
                }
            }
        }
    }

    // 参数
    .param-box {
        flex: 1;
        margin: 0 -16px;
        padding: 0 16px;
        overflow: auto;

        .param-list {
            display: grid;
            grid-template-columns: repeat(3, 1fr);
            grid-gap: 12px 15px;
        }

        .param-item {
            margin-top: 30px;

            .param-title {
                margin-bottom: 15px;
                font-size: 16px;
                font-weight: 500;
                color: #333333;
                line-height: 23px;
            }

            // 单选
            .param-radio {
                padding: 8px 6px;
                display: flex;
                align-items: center;
                justify-content: center;
                font-size: 14px;
                color: #333333;
                line-height: 20px;
                height: 100%;
                background: #f5f7fa;
                border-radius: 4px;
                word-wrap: break-all;
                box-sizing: border-box;

                &.is-active {
                    color: #3b7ffa;
                    background: rgba(51, 133, 255, 0.08);
                }
            }

            .van-row {
                margin-bottom: 15px;

                &:last-child {
                    margin-bottom: 0;
                }
            }

            // 日期范围选择
            .date-time-picker {
                display: flex;
                justify-content: space-between;
                align-items: center;
                color: #333333;

                .join-text {
                    flex: 0 0 auto;
                    margin: 0 15px;
                    font-size: 14px;
                    line-height: 20px;
                }

                .start,
                .end {
                    flex: 1;
                    display: flex;
                    align-items: center;
                    justify-content: center;
                    height: 40px;
                    font-size: 14px;
                    background: #f5f7fa;
                    border-radius: 4px;
                    color: #b5bcca;
                }
            }
        }
    }

    // 按钮
    .btn-box {
        flex: 0 0 auto;
        margin-top: 30px;
        padding: 15px 0;

        .van-button {
            height: 48px;
            font-size: 18px;
            color: #fff;
            background-color: #3b7ffa;
            border: none;

            &.reset {
                color: #3b7ffa;
                background-color: rgba(59, 127, 250, 0.14);
                border: 2px solid #e3e5e9;
            }
        }
    }
}
</style>
